<!--安排发货出库，订单列表-->
<template>
  <div class="contain">
    <!--tab-->
    <div class="dri-tab-wrap">
      <ul class="dri-tab cf">
        <li :class="{cur:step1}" @click="step(1)">
          <div class="dri-icon-box"><i class="iconfont icon-cargo"></i></div>
          <p>提货</p>
        </li>
        <li :class="{cur:step2}" @click="step(2)">
          <div class="dri-icon-box"><i class="iconfont icon-distribution1"></i></div>
          <p>交货</p>
        </li>
        <router-link tag="li" to="doneBill">
          <div class="dri-icon-box"><i class="iconfont icon-complete"></i></div>
          <p>完成</p>
        </router-link>
      </ul>
    </div>
    <!-- <div class="dri-btn-all cf" v-if="step1">
      <em class="f-l">AV201709120001070004</em>
      <div class="btn f-r" @click="pickVehicle">整车提货</div>
    </div>
    <div class="dri-btn-all cf" v-if="step2">
      <em class="f-l">AV201709120001070004</em>
      <div class="btn f-r" @click="transVehicle">整车中转</div>
    </div> -->
    <div class="acpt-list" v-for="item in todolist">
      <template v-if="item.BillState == 'P05' && step1">
        <div class="acpt-list-wrap mb30">
          <div class="acpt-list-head cf">
            <span class="time f-l">{{item.BillDate | timeshort}}</span>
          </div>
          <div class="displayflex acpt-list-body">
            <i class="iconfont icon-cargo"></i>
            <div class="txt flex1" @click="gotoDe(item)">
              <p class="ft17">{{item.MedName}}</p>
              <p>{{item.Province | province}} {{item.City | city}} {{item.District | district }} {{item.Address}}</p>
              <p>品种数：{{item.CountSum}}个</p>
              <div class="list-tag"><em class="tag">业务员</em>{{item.BuyerName}}</div>
            </div>
            <div class="acpt-list-btn" >
              <div class="btn mb10" @click="gotoDe(item)">提货</div>
            </div>
          </div>
        </div>
      </template>
      <template v-if="item.BillState == 'P09' && step2">
        <div class="acpt-list-wrap mb30">
          <div class="acpt-list-head cf">
            <span class="time f-l">{{item.BillDate | timeshort}}</span>
          </div>
          <div class="displayflex acpt-list-body">
            <i class="iconfont icon-cargo"></i>
            <div class="txt flex1" @click="consign(item)">
              <p class="ft17">{{item.MedName}}</p>
              <p>{{item.Province | province}} {{item.City | city}} {{item.District | district }} {{item.Address}}</p>
              <p>品种数：{{item.CountSum}}个</p>
              <div class="list-tag"><em class="tag">业务员</em>{{item.BuyerName}}</div>
            </div>
            <div class="acpt-list-btn" >
              <div class="btn mb10" @click="consign(item)">交货</div>
              <!-- <div class="btn mb10" @click="transBill">中转</div> -->
            </div>
          </div>
        </div>
      </template>
    </div>
    <div class="noDate_page" v-if="(step1 && step1Length<=0) || (step2 && step2Length<=0)">
      <div class="noDate_icon"><i class="iconfont icon-null"></i></div>
      暂无数据！
    </div>
    <manage-footer></manage-footer>
  </div>
</template>

<script>
import manageFooter from '@/components/core/footer/manage.footer.vue';
export default {
  name:'driverList',
  components: {
    manageFooter
  },
  data() {
    return {
      step1:true,
      step2:false,
      todolist:[],
      step1Length:0,
      step2Length:0,
    }
  },
  created(){
    if(this.$route.query.step && this.$route.query.step==2){
      this.step2 = true;
      this.step1 = false;
    }
    this.getdata();
  },
  watch: {
    
  },
  mounted() {
    this.$nextTick(function() {
      
    })
  },
  methods: {
    step(index){
      if (index==1) {
        this.step1 = true;
        this.step2 = false;
      }else if(index==2){
        this.step1 = false;
        this.step2 = true;
      }
    },
    pickVehicle(){
      this.$router.push({
        path:'/order/pickVehicle'
      })
    },
    transVehicle(){
      this.$router.push({
        path:'/order/transVehicle'
      })
    },
    transBill(){
      this.$router.push({
        path:'/order/transBill'
      })
    },
    consign(item){
      // sessionStorage.item =JSON.stringify(item);
      this.$router.push({
        path:'/order/consign',
        query:{
          id:item.Guid
        }
      })
    },
    gotoDe(item){
      // sessionStorage.item =JSON.stringify(item);
      this.$router.push({
        path:'/order/driverDetail',
        query:{
          id:item.Guid
        }
      })
    },
    //获取数据
    getdata(){
      var self = this;
      var userinfo = JSON.parse(localStorage.userinfo);
      var query = {
        CorpGuid: userinfo.CorpGuid,
        Page: 0,
        Rows: 9999,
      };
      this.Ajax.post('SearchOrderCode',query).then(function(resp){
        self.todolist = resp.Datas;
        self.todolist.forEach(function(item){
          if(item.BillState == 'P05'){
            self.step1Length+=1;
          };
          if(item.BillState == 'P09'){
            self.step2Length+=1;
          };
        });
      });
    },
  }
}
</script>